package com.review.Test.Master_Worker;

public class Main {
	
	public static void main(String[] args) {
		Worker worker = new Worker();
		//
		int num = Runtime.getRuntime().availableProcessors();
		System.out.println(num);
		Master master = new Master(worker, num);
		
		for (int i = 1; i <= 100; i++) {
			Task task = new Task();
			task.setId(i);
			task.setMoney(i);
			master.submit(task);
		}
		
		long start = System.currentTimeMillis();
		master.exexute();
		
		while (true) {
			if (master.isComplete()) {
				long expand = System.currentTimeMillis() - start;
				int summary = master.summary();
				System.out.println("结果：" + summary + "   耗时：" + expand);
				break;
			}
		}
		
	}

}
